package com.campus.common.config;

import com.campus.common.entity.AliOssProperties;
import com.campus.common.util.AliOssUtil;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OssConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public AliOssUtil aliOssUtil(AliOssProperties aliOssProperties){
        return new AliOssUtil(aliOssProperties.getEndpoint(),  //获取OSS的服务节点
                aliOssProperties.getAccessKeyId(),  //获取OSS的AccessKeyId(表示访问者身份的一种凭证)
                aliOssProperties.getAccessKeySecret(),//(AccessKeySecret 是与AccessKeyId相对应的密钥)
                aliOssProperties.getBucketName()); //获取阿里云的存储桶名称，存储桶是用于存储文件和数据的容器
    }
}
